﻿using LJX.SmartPark.Common.ResponseOutput;
using LJX.SmartPark.Domain.SafeManage.PatrolPerson;
using LJX.SmartPark.Domain.SafeManage.PatrolRecord;
using LJX.SmartPark.Domain.SafeManage.Train;
using LJX.SmartPark.Service.SafeManage;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static LJX.SmartPark.Service.SafeManage.TrainServeice;

namespace LJX.SmartPark.WebApi.Controllers.SafeManage
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "SafeManage")]
    public class TrainController : ControllerBase
    {
        private readonly ITrainServeice _trainServeice;

        public TrainController(ITrainServeice trainServeice)
        {
            _trainServeice = trainServeice;
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<bool>> PostAddTrain(Train input)
        {
            var result = _trainServeice.PostAddTrainAsync(input);
            return result;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="input"></param>
        [HttpDelete]
        public Task<Response<bool>> DeleteTrain(Train input)
        {
            var result = _trainServeice.DeleteTrainAsync(input);
            return result;
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> PutUpdateTrain(Train input)
        {
            var result = _trainServeice.PutUpdTrainAsync(input);

            return result;

        }

        /// <summary>
        /// 获取总条数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetCount()
        {
            return _trainServeice.GetCount();
        }

        /// <summary>
        /// 显示
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Response<List<Train>> GetTrainAsync(FyTrain fyTrain)
        {
            var result = _trainServeice.GetTrainAsync(fyTrain);
            return result.Result;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<Train> GetTrainById(Train input)
        {
            var result = _trainServeice.GetTrainById(input);
            return result;
        }
    }
}
